There are various types of recording media for recording digital data such as music content and video data, examples of which include a magnetic disk, an optical disk, and a magneto-optical disk. Among such recording media, memory cards that use a semiconductor memory such as a flash ROM as the recording element have rapidly become prevalent particularly in compact mobile devices such as digital still cameras and mobile phone terminals, due to the ability of the recording medium to be reduced in size. Moreover, in addition to applications as removable media as with conventional memory cards, semiconductor memory has recently been used in applications as internal device storage, such as incorporating a semiconductor memory such as a flash ROM into a device for use in place of a hard disk.
Mainly a semiconductor element called a NAND-type flash memory is used in such memory cards and internal device storage. A NAND-type flash memory is a recording element that, after previously recorded data has been erased once, can again record different data, and enables configuring an information recording device in which rewriting can be performed multiple times, likewise to conventional hard disks.
Conventionally, data stored in a memory card or internal device storage is managed using a file system. Managing data using a file system enables the data to be shared as a file between devices that can interpret the same file system, and therefore data stored by a user can be easily referenced and copied among multiple devices.
Conventionally, the most commonly used file system is called the FAT file system. The FAT file system is widely used as the file system in flexible disks, PC hard disks, memory cards, and the like due to having the characteristic that area management is performed in a unified manner by a table called a file allocation table (FAT), as well as having a relatively simple structure and being easily implemented.
FIG. 2 shows a configuration of the FAT file system.
Although there are various types of FAT file systems, such as FAT12, FAT16, and FAT32, which differ in the bid width used as the unit of management in the file allocation table, the method of area management using a file allocation table is substantially the same. The following describes FAT16 as an example.
As shown in FIG. 2, a file system management information area 301 exists at the head of a logical address space, and is an area for storing file system management information indicating the unit of area allocation, the size of the area managed by the file system, and the like.
The file system management information area 301 includes file system management information pieces called a master boot record (MBR) partition table 303, a partition boot sector 304, FATs (305 and 306), and a root directory entry 307, and also stores various information pieces necessary for managing a user data area 302.
The MBR partition table 303 is an area for storing information that is for managing a plurality of areas called partitions, into which an area in the logical address space managed by the file system has been divided.
The partition boot sector 304 is an area for storing information regarding management in a partition, such as the size of the unit of area management in the partition.
The FATs (305 and 306) are areas for storing information regarding the storage locations of data included in files, and normally there are two redundant FATs (305 and 306) that have the same information so that even if one of the FATs (305 and 306) is corrupted, files can be accessed using the other one of the FATs (305 and 306).
The root directory entry 307 is an area for storing information (directory entries) regarding files and directories that exist directly under the root directory.
Also, in the FAT file system, the user data area 302 for storing the data of actual files and the like follows the file system management information area 301.
The user data area 302 is divided into and managed in units of management called clusters that have a size of approximately 512 bytes to 32 KB, and data included in files is stored in the clusters. When a file stores a large amount of data, the data is stored across multiple clusters, and the connection between the clusters is managed by link information stored in the FATs (305 and 306).
Also, the information (directory entries) regarding files and subdirectories that exist in the directory directly under the root directory is stored with use of a portion of the user data area 302.
FIG. 3 is a diagram showing a configuration of a directory entry in FAT16.
A 32-byte directory entry 308 is allocated to each file and directory, and stores information regarding the file or directory. Specifically, each time a file or directory is added, information for a 32-byte directory entry 308 is newly created and recorded in the root directory entry 307 area or the user data area 302. The name of the file or directory is stored in eight bytes at the head of the directory entry 308.
The extension is stored in the next three bytes.
The next one byte stores attribute information such as a flag identifying the type of file or directory, or a flag identifying whether the file or directory is read-only.
Also, the directory entry 308 stores, for example, information regarding the last modified date/time of the file or directory, a starting cluster number indicating the location of the start of clusters in which the file or directory itself is stored, and the file size in numbers of bytes.
In this way, since the directory entry 308 holds only information regarding the location of the cluster in which the head data of the file is stored, if the file data is stored across multiple clusters, the location information regarding such clusters is held in the FATs (305 and 306). In other words, in the case of updating a file, in addition to writing the file data, it is necessary to write information in the directory entry 308 and the FATs (305 and 306) as well.
Next is a description of a procedure of processing for writing file data in the FAT file system with reference to FIG. 4.
(S401): read out the directory entry 308 for the target file.
(S402): acquire the starting cluster number stored in the directory entry 308 that was read out, and check the location of the head of the file data.
(S403): read out the FAT (305 or 306) to the RAM of the access module, follow the links in the FAT (305 or 306) in the RAM in order beginning from the file data head location that was acquired in S402, and acquire a writing location cluster number.
(S404): determine whether a new free area needs to be allocated to the file when writing the file data. If a free area needs to be allocated, proceed to the processing of S405. If a free area does not need to be allocated, proceed to the processing of S408.
(S405): search for a free area in the FAT (305 or 306) in the RAM, and acquire a one-cluster free area. Since a value of 0x0000 set in a FAT entry in the FATs (305 and 306) represents that the FAT entry is a free cluster, the processing for acquiring a free area is processing for acquiring a FAT entry having the value 0x0000 in the FAT (305 or 306). Specifically, the FAT entries in the FAT (305 or 306) in the RAM are sequentially referenced, a FAT entry whose value is set to 0x0000 is found, and the value of the cluster number corresponding to the found FAT entry is obtained. In the FAT entry search processing, it is possible to, for example, implement processing in order from the head of the FAT (305 or 306) to the tail, or implement processing starting from the FAT entry after the FAT entry that was previously allocated as a free area, returning to the head of the FAT (305 or 306) when the tail of the FAT (305 or 306) is reached, and then through to the FAT entry that was previously allocated as a free area. In this way, there are no particular limitations on the FAT entry search processing procedure as long as processing for searching for a free area among all the areas in the FAT (305 or 306) area can be realized.
(S406): set the value of the FAT entry corresponding to the free cluster number acquired in S405 to a value representing the link tail. Since a value of 0xFFFF set in a FAT entry in the FAT (305 or 306) represents that the FAT entry is the link tail, processing for setting the value of the corresponding FAT entry to 0xFFFF in the RAM is implemented in S406.
(S407): change the value of the FAT entry corresponding to the cluster number that is the current link tail in the RAM from 0xFFFF to the free cluster number acquired in S405. If a determination has been made in S404 that a free area needs to be acquired, data is added to the tail of the file. In this case, the links to the tail of the file have been followed in the link follow processing performed in S403, and therefore the value of the FAT entry corresponding to the cluster number of the current link tail is set to 0xFFFF, which represents that the FAT entry is the link tail. In the processing of S407, by connecting the link to the free cluster that was newly acquired in S405, the file links become one cluster-worth longer, thus enabling file data to be added.
(S408): write file data in the cluster at the writing location that is currently being referenced. If a determination has been made in S404 that a free area needs to be acquired, the currently referenced writing location is the free cluster that was acquired in S405. Also, if a determination has been made in S404 that a free cluster does not need to be acquired, the currently referenced writing location is the cluster that has been arrived at as a result of following the links in S403.
(S409): determine whether the writing of all of the file data has been completed. If any file data remains, the procedure returns to the processing of S404. On the other hand, if the writing of all of the file data has been completed, the procedure proceeds to the processing of S410.
(S410): update the information regarding the file size, the last modified date/time, and the like that is stored in the directory entry 308, and overwrite the directory entry 308 stored in the non-volatile memory of the information recording module.
(S411): overwrite the FAT (305 or 306) stored in the non-volatile memory of the information recording module with the data of the FAT (305 or 306) in the RAM of the access module, and then the processing is completed.
According to this file data writing processing, in the case of adding 10,000-byte data to “FILE1.TXT” shown in FIG. 5 that includes 60,000 bytes of data, the “FILE1.TXT” changes to a file including 70,000 bytes of data as shown in FIG. 6. Specifically, the cluster having the cluster number 6 is acquired as a free cluster, file data is added thereto, and a link connecting to the cluster number 6 is written to the FAT (305 or 306). As a result, the links of “FILE1.TXT” are updated from a condition of being made up of four clusters having the cluster numbers 2 to 5, to a condition of being made up of five clusters having the cluster numbers 2 to 6.
In this way, in the FAT file system, since file management information pieces are stored in both the FATs (305 and 306) and the directory entry 308, such information pieces also need to be updated when updating a file. Specifically, in the case where the access module updates a file stored in the information recording module, as shown in FIG. 7, the series of writing processing that is implemented includes file data (DATA) writing processing, directory entry 308 (DIR) writing processing, and FAT (305 and 306) (FAT1 and FAT2) writing processing.
In the case of storing a content file such as a high-definition video to the information recording module, the bit rate of the video is high, and therefore even if the directory entry 308 and the FATs (305 and 306) are updated at the rate of, for example, once every several seconds, the file data recording size is relatively large at approximately several MB, and file data is recorded in units of this relatively large recording size. Meanwhile, since only portions of the directory entry 308 and the FATs (305 and 306) in which information is to be updated are written to the information recording module, such information is recorded in units of the relatively small size of approximately 512 bytes to 32 KB.
In the case of using a NAND-type flash memory as the non-volatile memory of the information recording module, data needs to be erased once before other data is recorded. Since the size of the unit of erasing is from several hundred KB to several MB, in the case of implementing writing in units of a small size, “saving process” is executed in which valid data existing in the same physical block is copied to another block. For this reason, with a NAND-type flash memory, there is the problem that the recording speed decreases when writing data in smaller units than the unit of erasing, and this decrease in speed becomes remarkable particularly when writing file system management information such as the aforementioned directory entry 308 and FATs (305 and 306).
Also, in the case of implementing small-sized data writing by the saving process as well, large-sized data writing is executed, and thus there is the problem that the rewriting lifetime of the NAND-type flash memory becomes shorter.
Conventionally, as a method of solving such problems, a method has been proposed in which the access module notifies a data type to the information recording module when data writing is to be performed (e.g., see Patent Citation 1).
In this method (conventional technology), the access module notifies the information recording module, as the data type, whether data is large-sized file data or small-sized file system management information, and based on this notification, the data is sorted into either of two non-volatile memories that are provided in the information recording module and that have different units of management. Accordingly, both file data and file system management information are recorded at a high speed, and furthermore a decrease in the rewriting lifetime of the non-volatile memories can be prevented.    Patent Citation 1: WO 2005/043394A1